// components/TabBar/TabBar.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    currentIndex: Number
  },
  externalClasses: ['my-class'],
  /**
   * 组件的初始数据
   */
  data: {
    tabList: [
      '全部',
      '精华',
      '分享',
      '问答',
      '工作' 
    ],
    scrollLeft: 0
  },

  /**
   * 组件的方法列表
   */
  methods: {
    changeTab(e) {
      let idx = e.currentTarget.id;
      this.setData({
        currentIndex: idx
      })
      this.triggerEvent('getAjax', this.data.currentIndex)
      if(idx == 3) {
        this.setData({
          scrollLeft: 100
        })
      }else if(idx == 1) {
        this.setData({
          scrollLeft: 0
        })
      }
    }
  },
  lifetimes: {
    created() {
      console.log(this.data.currentIndex)
    }
  }
})
